package cn.iocoder.yudao.module.stock.api.stock;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;

import cn.iocoder.yudao.module.stock.api.stock.dto.StockRespDTO;
import cn.iocoder.yudao.module.stock.dal.dataobject.stock.StockDO;
import cn.iocoder.yudao.module.stock.service.stock.StockService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class StockApiImpl implements StockApi {

    @Resource
    private StockService stockService;
    @Override
    public CommonResult<StockRespDTO> getStockByProuctId(Long productId) {
        StockDO stock = stockService.getStockByProductId(productId);
        return CommonResult.success(BeanUtils.toBean(stock, StockRespDTO.class));
    }
}
